home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / private / _getcols.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  1.8 KB  |  88 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #ifdef UNIX
  4. #include <defs.h>
  5. #include <term.h>
  6. #endif
  7.  
  8. #ifdef PDCDEBUG
  9. char *rcsid__getcols = "$Header: C:\CURSES\private\RCS\_getcols.c 2.1 1993/06/18 20:22:46 MH Rel MH $";
  10. #endif
  11.  
  12.  
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   PDC_get_columns()    - return width of screen/viewport.
  18.  
  19.   PDCurses Description:
  20.      This is a private PDCurses function
  21.  
  22.      This function will return the width of the current screen.
  23.  
  24.   PDCurses Return Value:
  25.      This routine will return OK upon success and otherwise ERR will be
  26.      returned.
  27.  
  28.   PDCurses Errors:
  29.      There are no defined errors for this routine.
  30.  
  31.   Portability:
  32.      PDCurses    int    PDC_get_columns( void );
  33.  
  34. **man-end**********************************************************************/
  35.  
  36. int    PDC_get_columns(void)
  37. {
  38. #ifdef    DOS
  39.     int        cols;
  40.     char *env_cols;
  41. #endif
  42.  
  43. #ifdef    OS2
  44.     VIOMODEINFO modeInfo;
  45.     int cols;
  46.     char *env_cols;
  47. #endif
  48.  
  49.  
  50. #ifdef PDCDEBUG
  51.     if (trace_on) PDC_debug("PDC_get_columns() - called\n");
  52. #endif
  53.  
  54. #ifdef    FLEXOS
  55.     return( vir.vc_size.rs_ncols );
  56. #endif
  57.  
  58. #ifdef    DOS
  59. /* use the value from COLS environment variable, if set. MH 10-Jun-92 */
  60. /* and use the minimum of COLS and return from int10h    MH 18-Jun-92 */
  61.     regs.h.ah = 0x0f;
  62.     int86(0x10, ®s, ®s);
  63.     cols = (int)regs.h.ah;
  64.     env_cols = (char *)getenv("COLS");
  65.     if (env_cols != (char *)NULL)
  66.     {
  67.         cols = min(atoi(env_cols),cols);
  68.     }
  69.     return(cols);
  70. #endif
  71.  
  72. #ifdef    OS2
  73.     modeInfo.cb = sizeof(modeInfo);
  74.     VioGetMode(&modeInfo, 0);
  75.     cols = modeInfo.col;
  76.     env_cols = (char *)getenv("COLS");
  77.     if (env_cols != (char *)NULL)
  78.     {
  79.         cols = min(atoi(env_cols),cols);
  80.     }
  81.     return(cols);
  82. #endif
  83.  
  84. #ifdef UNIX
  85.     return(columns);
  86. #endif
  87. }
  88.